package com.yanqu.road.server.cmd.mogulbirthday;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.bossbirthday.MogulBirthdayProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.mogulbirthday.MogulBirthdayModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_MOGUL_BIRTHDAY_USER_GET_REWARD_FROM_CROSS, desc = "生辰收礼")
public class MogulUserGetRewardFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        MogulBirthdayProto.CrossMogulBirthdayUserGetRewardRespMsg respMsg = MogulBirthdayProto.CrossMogulBirthdayUserGetRewardRespMsg.parseFrom(packet.getBytes());

        ret = player.getModule(MogulBirthdayModule.class).myRewardFromCross(respMsg.getReward(), respMsg.getToday(), respMsg.getServerIdList(), respMsg.getBirthday());

    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            player.sendPacket(Protocol.U_MOGUL_BIRTHDAY_USER_GET_REWARD, MogulBirthdayProto.MogulBirthdayUserGetRewardRespMsg.newBuilder().setRet(ret));
        }
    }
}
